//
//  Small_MusicCD02_03.swift
//  TimMusic
//
//  Created by nkl on 2024/10/21.
//

import Foundation
import SwiftUI

struct Small_MusicCD03_01: View {
    var model: ControlMusicModel

    var body: some View {
        ZStack {
            Image("small_03_bg").resizable().ignoresSafeArea()
            VStack {
                ZStack(alignment: .topTrailing) {
                    Color(hex: "#111111")
                    VStack(alignment: .leading) {
                        HStack {
                            if let data = model.imageData, let uiImage = UIImage(data: data) {
                                Image(uiImage: uiImage).resizable()
                                    .frame(width: 43, height: 43)
                                    .cornerRadius(8)
                            } else {
                                Image("ic_small_placeholder").resizable()
                                    .frame(width: 43, height: 43)
                                    .cornerRadius(8)
                            }
                            
                            Spacer()
                        }
                        Text(model.title).font(.system(size: 14).bold()).foregroundColor(.white)
                        Text(model.auth).font(.system(size: 10)).foregroundColor(.white)
                    }.padding([.leading, .top])
                    if model.isPlay {
                        Image("ic_widget_pause").resizable().frame(width: 24, height: 24).padding([.top, .trailing])
                            .modifier(AppClickModifier(urlString: "timMusic://musicControl?option=\(OptionType.pause.rawValue)", isStatic: model.isStatic))
                    }else{
                        Image("ic_widget_play").resizable().frame(width: 24, height: 24).padding([.top, .trailing])
                            .modifier(AppClickModifier(urlString: "timMusic://musicControl?option=\(OptionType.play.rawValue)", isStatic: model.isStatic))
                    }
                }
                .cornerRadius(12)
                .frame(height: 100)
                Spacer()
            }.padding(8)
        }
    }
}
